package cn.schoolwow.util.test.module.query.jsonarray.flow.query;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class initialUserListDataJSONArrayFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        String password = "123456";

        JSONArray userArray = new JSONArray();
        for(int i=0;i<10;i++){
            JSONObject user = new JSONObject();
            user.put("username", "username"+i);
            user.put("password", password);
            user.put("userId", 1);
            user.put("age", i);
            userArray.add(user);
        }
        userArray.getJSONObject(0).remove("age");
        flowContext.putTemporaryData("userArray", userArray);
        flowContext.putTemporaryData("password", password);
    }

    @Override
    public String name() {
        return "初始化用户列表数据";
    }
}
